// pages/notice/langdu/report.js
let tool = require('../../../utils/tool.js');
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imageurl: 'https://yxpmaterial.oss-cn-beijing.aliyuncs.com/',
    reportInfo: {},
    navH: app.globalData.navHeight,
    pageName: '朗读分析',
      clientHeight: app.globalData.height
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.data.id = options.id;
    this.getdata();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  },
  getdata: function() {
    let that = this;
    let paramArr = {
      access_token: app.globalData.studentInfo.access_token,
      id: this.data.id
    }
    let rs = tool.getSign(paramArr, app.globalData.key); //返回 bodyParam heaer sign
    let sign = rs.sign;
    let apiUrl = app.globalData.apiURL + "message/listendeacon?sign=" + sign;
    let reportPro = new Promise(
      function(resolve, reject) {
        wx.request({
          url: apiUrl,
          header: rs.header,
          data: rs.bodyParam,
          method: 'post',
          success(res) {
            resolve(res);
          }
        })
      }

    );
    reportPro.then(function(rs) {
     
      if (rs.data.code == 1) {
        let res = rs.data.data;
        that.setData({
          reportInfo: res
        });
      } else if (rs.data.code == 10001) {
        wx.redirectTo({
          url: '/pages/login/login',
        })
      }
    });
  }
})